package com.ssm.auth.infra.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.ssm.auth.infra.basic.entity.AuthRole;
import com.ssm.auth.infra.basic.mapper.AuthRoleDao;
import com.ssm.auth.infra.basic.service.AuthRoleService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;

/**
 * (AuthRole)表服务实现类
 *
 * @author makejava
 * @since 2024-12-13 10:07:40
 */
@Service("authRoleService")
@Log4j2
public class AuthRoleServiceImpl implements AuthRoleService {
    @Resource
    private AuthRoleDao authRoleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AuthRole queryById(Long id) {
        return this.authRoleDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param authRole 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(AuthRole authRole) {
        if(log.isInfoEnabled()) {
            log.info("RoleController.add.authRole:{}", JSON.toJSONString(authRole));
        }
        return this.authRoleDao.insert(authRole);
    }

    /**
     * 修改数据
     *
     * @param authRole 实例对象
     * @return 实例对象
     */
    @Override
    public int update(AuthRole authRole) {
        if(log.isInfoEnabled()) {
            log.info("RoleController.update.authRole:{}", JSON.toJSONString(authRole));
        }
        return this.authRoleDao.update(authRole);
    }

    /**
     * 查询role角色
     * @param authRole
     * @return
     */
    @Override
    public AuthRole queryByCondition(AuthRole authRole) {
        AuthRole authRole1 = authRoleDao.queryByCondition(authRole);
        if(log.isInfoEnabled()) {
            log.info("RoleController.query.authRole:{}", JSON.toJSONString(authRole1));
        }
        return authRole1;
    }

}
